const tokenKey = 'token';

export function setToken(value: string) {
  localStorage.setItem(tokenKey, value);
}

export function getToken<T extends Record<string, any>>() {
  // const tokenVal = localStorage.getItem(tokenKey);
  // if (tokenVal) {
  //   const tokenObj: { expires: number } & T = JSON.parse(window.atob(tokenVal));
  //   return tokenObj;
  // }
  // return null;

  return getOriginToken();
}

export function getOriginToken() {
  return localStorage.getItem(tokenKey);
}

export function removeToken() {
  localStorage.removeItem(tokenKey);
}
